package com.ncp.servlet.order;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ncp.model.biz.order.ManageAddressBiz;
import com.ncp.model.entity.order.Receiver;
public class ManageAddressServlet extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		int userID = (Integer)request.getSession().getAttribute("userID");
		
		//String name = new String(request.getParameter("name").getBytes("iso-8859-1"), "UTF-8");
		String name = request.getParameter("name");
		String address = request.getParameter("address");
		String zip = request.getParameter("zip");
		String phone = request.getParameter("phone");
		String mobile = request.getParameter("mobile");
		String email = request.getParameter("email");
		
	//	System.out.println("name: " + name);
	//	System.out.println("address: " + address);
		
		Receiver receiver = new Receiver();
		receiver.setReceiver(name, address, zip, phone, mobile, email, userID);
		
		receiver.setId(1);		
		
		ManageAddressBiz biz = new ManageAddressBiz();		
		int addressID = biz.addReceiver(receiver);
	//	System.out.println("address ID: " + addressID);
		
		response.getWriter().write(addressID + "");
	}

}
